home *** CD-ROM | disk | FTP | other *** search
- unit fBuildMain;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- ExtCtrls, StdCtrls, ComCtrls, ToolWin, ActnList, Menus, Buttons, uBuildingObject;
-
- type
- TF_BuildMain = class(TForm)
- StatusBar1: TStatusBar;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- NewProject1: TMenuItem;
- OpenProject1: TMenuItem;
- SaveProject1: TMenuItem;
- N1: TMenuItem;
- Exit1: TMenuItem;
- Options1: TMenuItem;
- Compiler1: TMenuItem;
- Path1: TMenuItem;
- ClientDestination1: TMenuItem;
- ServerDestination1: TMenuItem;
- ActionList1: TActionList;
- A_newProject: TAction;
- A_saveProject: TAction;
- A_exit: TAction;
- A_ViewCompilerOptionsHelp: TAction;
- A_DebugCompilerOptions: TAction;
- A_defaultDestination: TAction;
- A_serverDestination: TAction;
- A_Build: TAction;
- A_addFile: TAction;
- Panel3: TPanel;
- Panel4: TPanel;
- Panel2: TPanel;
- Label2: TLabel;
- ToolBar2: TToolBar;
- M_LibraryPath: TMemo;
- Panel1: TPanel;
- Label1: TLabel;
- M_CFGFile: TMemo;
- Splitter1: TSplitter;
- Splitter2: TSplitter;
- Panel5: TPanel;
- Panel6: TPanel;
- Panel7: TPanel;
- L_progress: TLabel;
- Panel8: TPanel;
- Label3: TLabel;
- Label4: TLabel;
- Label5: TLabel;
- Splitter3: TSplitter;
- ToolBar3: TToolBar;
- ToolButton7: TToolButton;
- ToolButton8: TToolButton;
- ToolButton9: TToolButton;
- ToolButton10: TToolButton;
- M_Destination: TMemo;
- M_source: TMemo;
- Splitter4: TSplitter;
- OpenDialog: TOpenDialog;
- bb_Build: TBitBtn;
- b_exit: TBitBtn;
- tb_extract: TToolButton;
- A_extractPath: TAction;
- Panel9: TPanel;
- cb_ProjectList: TComboBox;
- Label6: TLabel;
- bb_newProject: TBitBtn;
- bb_save: TBitBtn;
- LB_exe: TListBox;
- A_DeleteFile: TAction;
- A_FileUp: TAction;
- A_fileDown: TAction;
- Action1: TAction;
- bb_halt: TBitBtn;
- A_openProject: TAction;
- b_setVerInfo: TButton;
- tb_editFilesINI: TToolButton;
- BitBtn2: TBitBtn;
- ToolBar1: TToolBar;
- lb_result: TListBox;
- tb_nexterror: TToolButton;
- tb_loadDPR: TToolButton;
- tb_loadPasfile: TToolButton;
- About1: TMenuItem;
- Button1: TButton;
- procedure A_saveProjectExecute(Sender: TObject);
- procedure A_extractPathExecute(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure cb_ProjectListChange(Sender: TObject);
- procedure LB_exeClick(Sender: TObject);
- procedure A_BuildExecute(Sender: TObject);
- procedure A_newProjectExecute(Sender: TObject);
- procedure A_addFileExecute(Sender: TObject);
- procedure A_fileDownExecute(Sender: TObject);
- procedure A_FileUpExecute(Sender: TObject);
- procedure A_DeleteFileExecute(Sender: TObject);
- procedure M_CFGFileChange(Sender: TObject);
- procedure A_exitExecute(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure bb_haltClick(Sender: TObject);
- procedure A_ViewCompilerOptionsHelpExecute(Sender: TObject);
- procedure A_defaultDestinationExecute(Sender: TObject);
- procedure tb_editFilesINIClick(Sender: TObject);
- procedure lb_resultDblClick(Sender: TObject);
- procedure tb_nexterrorClick(Sender: TObject);
- procedure tb_loadDPRClick(Sender: TObject);
- procedure tb_loadPasfileClick(Sender: TObject);
- procedure About1Click(Sender: TObject);
- procedure b_setVerInfoClick(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- private
- fProjectList : tstringlist;
- fProjectDir : string;
- fProjectName : string;
- fExeList : tstringlist;
- fProjectChanged : boolean;
- fHaltNow : boolean;
- fDefaultTargetDir : string;
- fMostRecentError : integer;
- fCurrentPas,
- fCurrentDPR : string;
- fBuildObj : TBuilderClass;
- procedure SaveProjectDialog;
- // save the three project files from the current set up
- procedure ReadProjectData;
- // read the three project files, files.ini, library.path, and base.cfg
- procedure HandleCompileEnd(const aSourceFile, aDestFile,
- aErrMsg: string; aSuccess: boolean; alines, ahints, awarnings,
- aerrors, afatal: integer);
- procedure HandleCompileNotify(const aSourcefile, Info: string);
- procedure HandleCompileStart(const aSourceFile, aDestFile,
- aErrMsg: string);
- procedure HandleProjectDone(const aProjectName: string; aOK, aErr,
- alines, ahints, awarnings, aerrors, afatal: integer);
- procedure HandleProjectHalt(const aSourcefile, Info : string);
- public
- { Public declarations }
- end;
-
- var
- F_BuildMain: TF_BuildMain;
-
- implementation
- uses inifiles, FileCtrl,
- uSelectDir, DOSToMemo, IDELibPath, fMainForm;
- // Fresourceeditor;
-
- const
- cProject = 'Projects';
- cDPR = 'DPR';
-
- {$R *.DFM}
-
-
-
-
- procedure TF_BuildMain.A_saveProjectExecute(Sender: TObject);
- var i : integer;
- begin
- chdir(fProjectDir);
- with tinifile.create(SlashSep(fprojectdir,'files.ini')) do begin
- for i := 0 to fExeList.count-1 do begin
- writeString(cDPR, fexeList.names[i], fexeList.values[fexeList.names[i]]);
- end;
- free;
- end;
- m_cfgfile.lines.SaveToFile('base.cfg');
- m_LibraryPath.lines.SaveToFile('Library.path');
- fProjectChanged := false;
- end;
-
-
- procedure TF_BuildMain.A_extractPathExecute(Sender: TObject);
- begin
- M_LibraryPath.lines.assign(GetIdeLibraryPath);
- fProjectChanged := true;
- end;
-
- procedure TF_BuildMain.FormCreate(Sender: TObject);
- var I : integer;
- begin
- fMostRecentError := 0;
- fProjectChanged := false;
- fProjectList := tstringlist.create;
- fExeList := tstringlist.create;
- with tinifile.create(ChangeFileExt(application.exename, '.ini')) do begin
- readSectionvalues(cProject, fProjectList);
- free;
- end;
- for i := 0 to fProjectList.count-1 do
- cb_projectList.items.add(fProjectList.names[i]);
- cb_projectList.text := '';
- if fProjectlist.count > 0
- then begin
- cb_ProjectList.itemindex := 0;
- fProjectName := fProjectList.names[cb_projectList.itemindex];
- fProjectDir := fProjectList.values[fProjectName];
- chdir(fProjectdir);
- end
- else cb_ProjectList.itemindex := -1;
-
- ReadProjectData;
- // Make sure we have a place to send dcu files to
- ForceDirectories('C:\Program Files\Borland\Delphi4\DCU');
- fBuildObj := TBuilderClass.create(self);
- end;
-
- Procedure TF_BuildMain.ReadProjectData;
- var i : integer;
- begin
- m_cfgFile.clear;
- if fileExists('Base.cfg')
- then m_cfgFile.lines.loadfromfile('Base.cfg');
- m_libraryPath.clear;
- if fileExists('Library.path')
- then m_LibraryPath.lines.loadfromFile('Library.path');
- fExeList.clear;
- lb_exe.clear;
- m_source.clear;
- m_destination.clear;
- if fprojectdir = '' then exit;
- with tinifile.create(SlashSep(fprojectdir,'files.ini')) do begin
- readSectionValues(cDPR, fExeList);
- for i := 0 to fExeList.count-1 do begin
- LB_exe.items.add(extractFileName(fExeList.names[i]));
- end;
- free;
- end;
- fProjectChanged := false;
- lb_execlick(nil);
- end;
-
- procedure TF_BuildMain.cb_ProjectListChange(Sender: TObject);
- begin
- If cb_projectList.itemindex = -1
- then exit
- else begin
- if fProjectChanged
- then SaveProjectDialog;
- fProjectName := fProjectList.names[cb_projectList.itemindex];
- fProjectDir := fProjectList.values[fProjectName];
- chdir(fProjectdir);
- ReadProjectData;
- bb_build.enabled := true;
- bb_build.default := true;
- end;
- end;
-
- procedure TF_BuildMain.LB_exeClick(Sender: TObject);
- begin
- if lb_exe.items.count = 0
- then exit;
- if (lb_exe.itemindex = -1)
- and
- (lb_exe.items.count > 0)
- then lb_exe.itemindex := 0;
- m_destination.text := fexeList.names[lb_exe.itemindex];
- m_source.text := fexeList.values[fexeList.names[lb_exe.itemindex]];
- end;
-
-
-
- Procedure TF_BuildMain.HandleCompileNotify(const aSourcefile, Info : string);
- begin
- l_progress.caption := asourcefile + ': '+Info;
- StatusBar1.simpleText := asourcefile + ': '+Info;
- end;
-
- Procedure TF_BuildMain.HandleCompileStart(const aSourceFile, aDestFile, aErrMsg : string);
- begin
- l_progress.caption := 'Compiling '+asourcefile + ' to '+aDestFile+': '+aErrMsg;
- end;
-
- Procedure TF_BuildMain.HandleCompileEnd(const aSourceFile, aDestFile, aErrMsg : string; aSuccess : boolean; alines, ahints, awarnings, aerrors, afatal : integer);
- begin
- l_progress.caption := 'Done with '+asourcefile + ' to '+aDestFile+': '+aErrMsg;
- StatusBar1.simpleText := 'Error: '+aErrMsg+' Lines: '+IntToStr(alines)+ ', Hints: '+IntToStr(aHints)+ ', Warnings: '+IntToStr(aWarnings)+', Errors: '+IntToStr(aErrors)+', Fatal: '+IntToStr(aFatal);
- if not aSuccess
- then if MessageDlg('Compile error. Do you want to halt the build?', mtconfirmation, [mbyes, mbNo],0) = mrYes
- then fBuildObj.HaltNow := true;
- lb_result.items.assign(fBuildObj.ProjectSummary);
- end;
-
- Procedure TF_BuildMain.HandleProjectDone(const aProjectName : string; aOK, aErr, alines, ahints, awarnings, aerrors, afatal : integer);
- begin
- StatusBar1.simpleText := 'Final result is '+IntToStr(aOK)+' OK, '+IntToStr(aErr)+' ERR. Lines: '+IntToStr(alines)+ ', Hints: '+IntToStr(aHints)+ ', Warnings: '+IntToStr(aWarnings)+', Errors: '+IntToStr(aErrors)+', Fatal: '+IntToStr(aFatal);
- lb_result.items.assign(fBuildObj.ProjectSummary);
- lb_result.items.addstrings(fBuildObj.ProjectResults);
- end;
-
- Procedure TF_BuildMain.HandleProjectHalt(const aSourcefile, Info : string);
- begin
- StatusBar1.simpleText := 'Project halted: '+aSourceFile +': '+Info;
- l_progress.caption := 'Project halted: '+Info;
- end;
-
-
-
- procedure TF_BuildMain.A_BuildExecute(Sender: TObject);
- begin
- fHaltNow := false;
- bb_halt.enabled := true;
- bb_build.enabled := false;
- lb_result.items.clear;
- lb_result.color := clWhite;
- A_viewCompilerOptionsHelp.Checked := false;
- l_progress.caption := 'Starting project '+fprojectdir;
- LB_exe.itemindex := 0;
-
- fBuildObj.ProjectName := 'testing';
- fBuildObj.ProjectDir := fProjectdir;
- fBuildObj.OnCompileEvent := HandleCompileNotify;
- fBuildObj.OnCompileStart := HandleCompileStart;
- fBuildObj.OnCompileEnd := HandleCompileEnd;
- fBuildObj.OnProjectDone := HandleProjectDone;
- fBuildObj.OnProjectHalt := HandleProjectHalt;
- fBuildObj.execute;
- b_exit.default := true;
- end;
-
- {
- var errMsg, cmdline,
- UnitSearchPath, tmp : string;
- success : boolean;
- i, j, subLines, totlines, subHints, totHints, subWarn, totWarn,
- subErr, totErr, subFat, totFat, OKs, errs : integer;
- tmpsl, configFile, pathFile,
- results, summary : tstringlist;
- st, et: TDateTime;
- h, m, s, ms: Word;
- begin
- try
- fHaltNow := false;
- bb_halt.enabled := true;
- tmpsl := tstringlist.create;
- results := tstringlist.create;
- summary := tstringlist.create;
- summary.add('Build started '+FormatDateTime('ddd, dd mmm yyyy hh:nn:ss', now)+#13#10);
- lb_exe.itemindex := 0;
- A_saveProjectExecute(Sender);
- chdir(fProjectdir);
- totlines := 0;
- totHints := 0;
- totWarn := 0;
- totErr := 0;
- totFat := 0;
- OKs := 0;
- Errs := 0;
- lb_result.items.clear;
- lb_result.color := clWhite;
- A_viewCompilerOptionsHelp.Checked := false;
- l_progress.caption := 'Starting project '+fprojectdir;
- LB_exe.itemindex := 0;
- for i := 0 to fexeList.count-1 do begin
- if fHaltNow then break;
- LB_exeClick(sender);
- with fBuildObj do begin
- InFile := extractFilePath(application.exename)+'builder.ini';
- Outfile := SlashSep(fProjectDir,'dump.dat');
- ProjectDir := fProjectDir;
- SourceFullFileName := m_source.text;
- if pos('.RC', m_source.text) = 0
- then CompileType := ctDPR
- else CompileType := ctRC;
- DestinationFullFileName := m_destination.text;
- OnCompile := HandleBuildNotify;
- if Execute
- then begin
- if Success
- then Inc(OKs)
- else Inc(Errs);
- TotLines := TotLines+Lines;
- TotWarn := TotWarn+Warnings;
- TotHints :=TotHints+Hints;
- TotErr := TotErr+Errors;
- TotFat := TotFat+Fatals;
- end
- else begin
- Inc(Errs);
- end;
- TotLines := TotLines + lines;
- tmp := IntToStr(OKs)+' OK, '+IntToStr(Errs)+' ERR. Lines: '+IntToStr(Totlines)+ ', Hints: '+IntToStr(TotHints)+ ', Warnings: '+IntToStr(TotWarn)+', Errors: '+IntToStr(TotErr)+', Fatal: '+IntToStr(TotFat);
- StatusBar1.simpleText := tmp;
- lb_Result.items.assign(Results);
- end;
- Application.processMessages;
- Summary.addstrings(lb_result.items);
- lb_exe.itemindex := lb_exe.itemindex + 1;
- if lb_exe.itemindex = lb_exe.items.count
- then break;
- end;
- tmp := 'Final result is '+IntToStr(OKs)+' OK, '+IntToStr(Errs)+' ERR. Lines: '+IntToStr(TotLines)+ ', Hints: '+IntToStr(TotHints)+ ', Warnings: '+IntToStr(TotWarn)+', Errors: '+IntToStr(TotErr)+', Fatal: '+IntToStr(TotFat);
- fBuildObj.results.insert(0,tmp);
- //fBuildObj.SaveResults;
- lb_result.items.assign(results);
- except
- on e:exception do begin
- results.Insert(0, 'Exception thrown: '+e.message+#13#10);
- lb_result.items.assign(results);
- lb_result.items.saveToFile(outfile);
- end;
- end;
- bb_halt.enabled := false;
- results.Free;
- tmpsl.free;
- configFile.free;
- PathFile.free;
- summary.free;
- end;
- }
-
- procedure TF_BuildMain.A_newProjectExecute(Sender: TObject);
- var dir : string;
- i : integer;
- begin
- if MySelectDirectory('Select Project specs directory', dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0)
- then begin
- if fProjectChanged
- then SaveProjectDialog;
- fProjectDir := dir;
- for i := length(dir) downto 1 do
- if dir[i] = '\'
- then begin
- fProjectName := copy(dir, i+1, 200);
- break;
- end;
- cb_projectList.items.add(fprojectNAme);
- cb_projectList.text := fProjectNAme;
- fProjectList.add(fProjectName+'='+fProjectDir);
- chdir(fProjectDir);
- ReadProjectData;
- with tinifile.create(ChangeFileExt(application.exename, '.ini')) do begin
- writeString(cProject, fProjectName, fProjectDir);
- free;
- end;
- end;
- end;
-
- procedure TF_BuildMain.A_addFileExecute(Sender: TObject);
- var i : integer;
- dir, fname : string;
- begin
- with opendialog do begin
- filter := 'Project files (dpr, dpk, rc)|*.dpr;*.dpk;*.rc';
- options := [ofHideReadOnly,ofAllowMultiSelect,ofPathMustExist,ofFileMustExist,ofEnableSizing];
- Title := 'select file(s) (dpr, dpk or rc) to be in project';
- if execute
- then begin
- for i := 0 to files.count-1 do begin
- fname := extractfilename(files[i]);
- dir := fDefaultTargetDir;
- if not MySelectDirectory('Select Target Directory', dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0)
- then dir := extractFilePath(files[i]);
- if pos('.exe', fname) > 0
- then fname := changeFileExt(fname, '.exe')
- else if pos('.dpk', fname) > 0
- then fname := changeFileExt(fname, '.bpl')
- else if pos('.rc', fname) > 0
- then fname := changeFileExt(fname, '.res');
- lb_exe.items.add(fname);
- fExeList.add(dir+'\'+fname+'='+files[i]);
- fProjectChanged := true;
- lb_exe.itemindex := lb_exe.items.count-1;
- lb_exeClick(sender);
- end;
- end;
- end;
- end;
-
- procedure TF_BuildMain.SaveProjectDialog;
- begin
- If MessageDlg('Project '+fProjectdir+' has changed. Do you wish to save the changes?', mtConfirmation, [mbYEs, mbNo],0) = mrYes
- then A_saveProjectExecute(nil);
- end;
-
- procedure TF_BuildMain.A_fileDownExecute(Sender: TObject);
- var i : integer;
- begin
- i := lb_exe.itemindex;
- if (i = -1) or (i = lb_exe.items.count-1) then exit;
- lb_exe.Items.Move(lb_exe.itemindex, lb_exe.itemindex+1);
- fExeList.Move(i, i+1);
- lb_exe.itemindex := i+1;
- fProjectChanged := true;
- LB_exeClick(sender);
- end;
-
- procedure TF_BuildMain.A_FileUpExecute(Sender: TObject);
- var i : integer;
- begin
- i := lb_exe.itemindex;
- if (i = -1) or (i = 0) then exit;
- lb_exe.Items.Move(lb_exe.itemindex, lb_exe.itemindex-1);
- fExeList.Move(i, i-1);
- lb_exe.itemindex := i-1;
- fProjectChanged := true;
- LB_exeClick(sender);
- end;
-
- procedure TF_BuildMain.A_DeleteFileExecute(Sender: TObject);
- var i : integer;
- begin
- i := lb_exe.itemindex;
- if i = -1 then exit;
- lb_exe.items.delete(i);
- fexeList.delete(i);
- fProjectChanged := true;
- LB_exeClick(sender);
- end;
-
- procedure TF_BuildMain.M_CFGFileChange(Sender: TObject);
- begin
- fProjectChanged := true;
- end;
-
- procedure TF_BuildMain.A_exitExecute(Sender: TObject);
- begin
- if fProjectChanged
- then SaveProjectDialog;
- close;
- end;
-
- procedure TF_BuildMain.FormClose(Sender: TObject;
- var Action: TCloseAction);
- begin
- if fProjectChanged
- then SaveProjectDialog;
- Action := caFree;
- end;
-
- procedure TF_BuildMain.bb_haltClick(Sender: TObject);
- begin
- fHaltNow := true;
- end;
-
- procedure TF_BuildMain.A_ViewCompilerOptionsHelpExecute(Sender: TObject);
- begin
- lb_result.clear;
- if A_viewCompilerOptionsHelp.Checked
- then begin
- lb_result.clear;
- lb_result.color := clWhite;
- l_progress.caption := '';
- A_viewCompilerOptionsHelp.Checked := false;
- end
- else begin
- l_progress.caption := 'DCC32 options';
- lb_result.color := clGray;
- lb_result.items.loadfromFile(extractFilePath(application.exename)+'\options.txt');
- A_viewCompilerOptionsHelp.Checked := true;
- end;
- end;
-
- procedure TF_BuildMain.A_defaultDestinationExecute(Sender: TObject);
- var dir : string;
- begin
- if MySelectDirectory('Select Default Target Directory', dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0)
- then fDefaultTargetDir := dir;
- end;
-
- procedure TF_BuildMain.tb_editFilesINIClick(Sender: TObject);
- begin
- lb_result.items.LoadFromFile(fProjectDir+'Files.ini');
- end;
-
-
- procedure TF_BuildMain.lb_resultDblClick(Sender: TObject);
- begin
- l_progress.caption := lb_result.items[lb_result.itemindex];
- end;
-
- procedure TF_BuildMain.tb_nexterrorClick(Sender: TObject);
- var i,j : integer;
- tmp : string;
- begin
- for i := fMostRecentError+1 to lb_result.items.count-1 do begin
- if pos(' Error: ', lb_result.items[i]) <> 0
- then begin
- fMostRecentError := i;
- fCurrentPas := copy(lb_result.items[i], 1, pos('(', lb_result.items[i])-1);
- if pos('\', fCurrentPas) = 0
- then fCurrentPas := extractFilePath(fCurrentDPR)+fcurrentpas;
- break;
- end;
- tmp := 'DCC started: DCC32.exe ';
- if pos(tmp, lb_result.items[i]) <> 0
- then begin
- tmp := copy(lb_result.items[i], length(tmp), 100);
- tmp := trim(copy(tmp, 1, pos('.', tmp)));
- for j := 0 to lb_exe.items.count-1 do
- if pos(uppercase(tmp), uppercase(lb_exe.items[j])) = 1
- then begin
- lb_exe.itemindex := j;
- fCurrentDPR := fexeList.values[fexeList.names[j]];
- end;
- end;
- if i = lb_result.items.count-1
- then l_progress.caption := 'No more errors';
- end;
- lb_result.itemindex := fMostRecentError;
- end;
-
- procedure TF_BuildMain.tb_loadDPRClick(Sender: TObject);
- var cmdline : string;
- success : boolean;
- SI: TStartupInfo;
- PI: TProcessInformation;
- begin
- FillChar(SI, SizeOf(SI), 0);
- cmdline := 'Delphi32.exe /hm /hv '+fCurrentDPR; // /np means no project, just the file
- success := CreateProcess(nil,pchar(cmdline),nil,nil,True,NORMAL_PRIORITY_CLASS,
- nil,nil,SI, PI);
- if not success
- then showmessage('error launching Delphi');
-
- end;
-
- procedure TF_BuildMain.tb_loadPasfileClick(Sender: TObject);
- var cmdline : string;
- success : boolean;
- SI: TStartupInfo;
- PI: TProcessInformation;
- begin
- FillChar(SI, SizeOf(SI), 0);
- cmdline := 'Delphi32 /hm /hv '+fCurrentPas; // /np means no project, but won'just the file
- success := CreateProcess(nil,pchar(cmdline),nil,nil,True,NORMAL_PRIORITY_CLASS,
- nil,nil,SI, PI);
- if not success
- then showmessage('error launching Delphi');
- end;
-
- procedure TF_BuildMain.About1Click(Sender: TObject);
- begin
- // MOHAboutDialog1.execute;
- end;
-
- procedure TF_BuildMain.b_setVerInfoClick(Sender: TObject);
- begin
- Showmessage('set changes to version info in the myproject.ver file file; '#13#10'there needs to be an myproject.ico file present also');
- end;
-
- procedure TF_BuildMain.Button1Click(Sender: TObject);
- begin
- F_MainForm := TF_MainForm.create(application);
- f_mainForm.showmodal;
-
- end;
-
- end.
-